const express = require('express')
    //导入数据库
const expressJoi = require('@escook/express-joi')
    //创建路由对象
const router = express.Router()
    //导入加密密码包
const joi = require('joi')
    //导入自定义验证规则包

//导入验证表单数据的中间件

//用户名验证规则
const username = joi.string().alphanum().min(3).max(10).required()
    //密码验证规则
const password = joi.string().pattern(/^[\S]{6,12}$/).required()

//登录表单验证规则对象
const login_schema = {
    body: {
        username,
        password,
    }
}

const userHandele = require('../router_handler/user.js')

//登录接口
router.post('/login', expressJoi(login_schema), userHandele.login)

module.exports = router